using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Web.Core;
using Web.Core.Objects;

public partial class AdminCP_Currencies : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ArrayList arrCurrencies = Currencies.GetAllCurrencies();
        if (!IsPostBack)
        {
            this.rptCurrencies.DataSource = arrCurrencies;
            this.rptCurrencies.DataBind();
        }
        // ---------------------------------------
        if (Request.Params["do"] != null)
        {
            string cDo = Request.Params["do"];
            switch (cDo)
            {
                case "edit":
                    if (Request.Params["cid"] != null)
                        LoadControls();
                    break;
                case "add":
                    LoadControls();
                    break;
                case "del":
                    if (Request.Params["cid"] != null)
                    {
                        int curID = 0;
                        try
                        {
                            curID = int.Parse(Request.Params["cid"].ToString());
                        }
                        catch { }
                        Currencies.Delete(new Currency(curID, "", "", 0));
                        this.PreRenderComplete += new EventHandler(AdminCP_Currencies_PreRenderComplete);
                    }
                    break;
                default:
                    break;
            }
        }
    }
    void LoadControls()
    {
        Control addEditCurrencies = (Control)Page.LoadControl("~/AdminCP/AdminControls/AddEditCurrencies.ascx");
        this.PlaceHolderBottom.Controls.Add(addEditCurrencies);
    }
    protected void AdminCP_Currencies_PreRenderComplete(object sender, EventArgs e)
    {
        Response.Redirect("Currencies.aspx");
    }
}
